﻿<%@ WebHandler Language="C#" Class="wxMiniProgramLogin" %>
using Models;
using System;
using System.Web;
using Newtonsoft.Json;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.Net;
using Newtonsoft.Json.Linq;


public class wxMiniProgramLogin : IHttpHandler {
    public void ProcessRequest (HttpContext context) {
        context.Response.ContentType = "text/plain";

   


        string openid = context.Request.Headers["X-ACCESS-USER"];//Header中的token

        if (string.IsNullOrEmpty(openid))
        {
            HttpContext.Current.Response.Write("parameter error");
            return;
        }


        var code = 1;
        var msg = "收货地址";
        var time = DateTime.Now;

        using (Entities bll = new Entities())
        {

            var data = bll.S_UADDRESS.Where(p => p.Uopenid == openid).Select(x=>new
            {
                id = x.UAID,
                address_id = x.UAID,
                is_default = x.UAState,
                name = x.UPeopleName,
                phone = x.UAPhone,
                province_name = x.UAProvance,
                city_name = x.UACity,
                area_name = x.UADistrict,
                addr = x.UDetailAddress,
                x.UAddName

            }).ToList();

            context.Response.Write(JsonConvert.SerializeObject(new { code,msg,time,data}));
            

        }

        HttpContext.Current.Response.End();
    }





    public bool IsReusable {
        get {
            return false;
        }
    }

}